import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @ClassName LC1408
 * @Author ykx
 * @Date 2024/7/6 13:02
 * @Version 1.0
 */
public class LC1408 {
    public static void main(String[] args) {
        LC1408 lc1408 = new LC1408();
        System.out.println(lc1408.stringMatching(new String[]{"leetcode", "et", "code"}));
    }

    public List<String> stringMatching(String[] words) {
        Set<String> set = new HashSet<>();
        for (int i = 0; i < words.length; i++) {
            for (int j = 0; j < words.length; j++) {
                if (j == i) {
                    continue;
                } else {
                    if (words[i].contains(words[j])) {
                        set.add(words[j]);
                    }
                }
            }
        }
        return new ArrayList<>(set);
    }


}
